#include <bits/stdc++.h>
#include <string>
#include <stack>
#include <vector>
#include <iostream>

using namespace std;

struct point
{
    int x,y;
    int val;
};

int main()
{
    int N;  
    while(cin >> N)
    {
        vector<point> buf(N);
        string str;
        stack<point> sta;
        stack<char> op;
        for(int i = 0; i < N; ++i)
        {
            std::cin >> buf[i].x >> buf[i].y;
        }
        cin >> str;
        int index = 0;
        for(int i = 0; i < str.size(); ++i)
        {
            switch(str[i])
            {
                case '(':
                    op.push(str[i]);
                    break;
                case ')':
                    op.pop();
                    point left,right;
                    right = sta.top();
                    sta.pop();
                    left = sta.top();
                    sta.pop();
                    point tmp;
                    tmp.x = left.x;
                    tmp.y = right.y;
                    tmp.val = left.val + right.val + left.x * left.y * right.y;
                    sta.push(tmp);
                    break;
                default:
                    sta.push(buf[index++]);
            }
        }
        cout << sta.top().val << endl;
        sta.pop();
    }
    return 0;
}